﻿@{
    ViewData["Title"] = "职位管理";
}
<div class="layui-layout layui-layout-admin">
    <div id="testdemo"></div>
</div>

@section scripts {
    <script type="text/javascript">
        var app = {};
        layui.use(['formDesigner', 'http', 'toast'], function () {

            var form = layui.form,
                toast = layui.toast,
                tree = layui.tree,
                http = layui.http,
                formDesigner = layui.formDesigner;
            //
            app.init = function () {
                //var data = app.data || {};
                //form.val('val-filter', data);
                if (window.localStorage.getItem('layui_form_json') !== undefined) {
                    demojs = JSON.parse(window.localStorage.getItem('layui_form_json'));
                    render = formDesigner.render({
                        elem: '#testdemo',
                        data: demojs,
                        viewOrDesign: true,
                        formData: { "textarea_1": "123", "input_2": "123", "password_3": "123" }
                    });
                }
            }();
            app.save = function () {
                form.submit('val-filter', function (data) {
                    var postData = data.field;
                    //
                    var url = postData.id == '0' ? '/api/sysPos/add' : '/api/sysPos/update'
                    http.post(url, postData).then((res) => {
                        if (res.code == 200) {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload('lsttable');
                            toast.success({ message: '保存成功！' });
                        }
                        else {
                            layer.alert('保存失败，错误信息:' + res.message, { icon: 2 });
                        }
                    });
                    return false;
                });
            }
        })
    </script>
}
